package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.City;
import com.pgybook.db.entity.domain.CityEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface CityMapper {
    int countByExample(CityEx example);

    int deleteByExample(CityEx example);

    @Delete({
            "delete from city",
            "where CITYID = #{cityid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer cityid);

    @Insert({
            "insert into city (CITYNAME, PRVID, ",
            "CODE)",
            "values (#{cityname,jdbcType=VARCHAR}, #{prvid,jdbcType=INTEGER}, ",
            "#{code,jdbcType=VARCHAR})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "cityid", before = false, resultType = Integer.class)
    int insert(City record);

    int insertSelective(City record);

    List<City> selectByExample(CityEx example);

    @Select({
            "select",
            "CITYID, CITYNAME, PRVID, CODE",
            "from city",
            "where CITYID = #{cityid,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    City selectByPrimaryKey(Integer cityid);

    int updateByExampleSelective(@Param("record") City record, @Param("example") CityEx example);

    int updateByExample(@Param("record") City record, @Param("example") CityEx example);

    int updateByPrimaryKeySelective(City record);

    @Update({
            "update city",
            "set CITYNAME = #{cityname,jdbcType=VARCHAR},",
            "PRVID = #{prvid,jdbcType=INTEGER},",
            "CODE = #{code,jdbcType=VARCHAR}",
            "where CITYID = #{cityid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(City record);
}
